package com.xuecheng.content.feginclient;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/*只要熔断了就会执行这个降级的方法
* */
@Component
@Slf4j
public class MediaServiceClientFallbackFactory implements FallbackFactory<MediaServiceClient>/*加入远程调用的接口*/ {
    //拿取到了熔断的异常信息
    @Override
    public MediaServiceClient create(Throwable throwable) {
        return new MediaServiceClient() {
            //发生在熔断的降级操作
            @Override
            public String upload(MultipartFile filedata, String objectName) throws IOException {
                log.debug("调用远程调用之后的异常信息是"+throwable.toString(),throwable);
                          return "123";
            }
        };
    }
}
